#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QStateMachine>
#include <QState>
#include <QTimer>
#include <QPair>
#include "touchexmppclient.h"
#include "QXmppMessage.h"
#include "manager.h"
#include "xmlreader.h"
#include "channel.h"
#include "manager.h"
#include <QTabWidget>
namespace Ui
{
    class ColaborationWindow;
}

struct UserData{
    QString login;
    QString password;
};

class ColaborationWindow : public QTabWidget
{
    Q_OBJECT

public:
    ColaborationWindow(Touche::ColaborativeManager *manager, QWidget *parent = 0);
    ~ColaborationWindow();
    //ToucheXmppClient *client;
    QString diffPatchMsg(QString msg = "");
    void addUserInChannelView(QString channeSelected);
    //QMap<QString, Channel*> channels;
    bool validateEnterChannel(QString channelSelected);
private:
    Ui::ColaborationWindow *ui;
    QStateMachine *machine;
    Touche::ColaborativeManager * m_manager;
    //QMap<QString, Channel*> channels;
    void updateChannelsView();
    bool loginIsInChannel(QTreeWidgetItem *channel);
    //    bool existsChannel(QString name);
public slots:
    void sendStringToChat(const QXmppMessage& msg);
    void onChatText(const QString &text);
    void loadBuddies();
    void connectionError();
    void contactsChanged();
    void channelsChanged();
    void on_messageReceived(QXmppMessage);
private slots:
    void on_b_send_channel_clicked();
    void on_b_startPrivateChat_clicked();
    void on_remove_buddy_clicked();
    void on_enter_button_clicked();
    void on_add_buddy_clicked();
    void on_desconect_button_clicked();
    void on_b_send_buddy_clicked();
    void on_create_channel_button_clicked();

signals:
    void newBuddyRequest(QString);
    void buddyRemove(QString);
};

#endif // MAINWINDOW_H
